import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
    state: {
        count: 0
    },
    getters:{
      evenOrOdd(state){
          return state.count % 2 === 0 ? 'even' : 'odd'
      }
    },
    mutations: {
        increase(state){
            state.count++;
        },
        decrease(state){
            state.count--;
        }
    },
    actions:{
        incrementAsync ({ commit }) {
            setTimeout(() => {
                commit('increase')
            }, 1000)
        }
    }
})

export default store